package com.pinyoumei.app.view.TextViewHelper;

/**
 * Created by Administrator on 2020-12-15.
 * --------- 日期 ------- 维护人 ------------ 变更内容 --------
 * 2020-12-15        Administrator             新增Person类
 * 2020-12-15        Administrator             增加sex属性
 */

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.SpannableString;
import android.text.Spanned;

import com.pinyoumei.app.R;


public class TextViewHelper {

    /**
     * @param context 上下文
     * @param flag 商品类别
     * @param msg  商品名称
     * @return
     */
    public static SpannableString setLeftImage(Context context, String flag, String msg) {
        SpannableString spannableString = new SpannableString("  " + msg);
        Drawable rightDrawable = null;
        switch (flag) {
        	case "tb":
                rightDrawable = context.getResources().getDrawable(R.mipmap.ic_tb_bg);
        		break;

            case "jd":
                rightDrawable = context.getResources().getDrawable(R.mipmap.ic_jd_bg2);
                break;
            case "wph":
                rightDrawable = context.getResources().getDrawable(R.mipmap.ic_wph_bg);
                break;
            case "tm":
                rightDrawable = context.getResources().getDrawable(R.mipmap.ic_tm_bg);
                break;
            case "pdd":
                rightDrawable = context.getResources().getDrawable(R.mipmap.ic_pdd_bg);
                break;
            case "sn":
                rightDrawable = context.getResources().getDrawable(R.mipmap.ic_sn_bg);
                break;

        	default:
        		break;
        }

//        rightDrawable.setBounds(0, 0, 40,40);
        rightDrawable.setBounds(0, 0, rightDrawable.getIntrinsicWidth(), rightDrawable.getIntrinsicHeight());

        spannableString.setSpan(new MyImageSpan(rightDrawable), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        return spannableString;
    }

}